<template>
  <el-image :src="src">
    <el-image
      slot="error"
      :src="avatar"
    />
  </el-image>
</template>

<script>
export default {
  props: {
    src: {
      type: String,
      default: ''
    },
    uid: {
      type: [Number, String],
      default: 1
    }
  },
  computed: {
    avatar() {
      const formatUid = this.uid.toString();
      let random = formatUid[formatUid.length - 1];
      if (random === '0' || random === '9') {
        random = 1;
      }
      return `./static/default_avatar/default_avatar_${random}.jpg`;
    }
  }
};
</script>
